package com.wt.dao;

import com.wt.pojo.WithdrawOrder;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface WithdrawOrderMapper {
    @Delete({
        "delete from brand_admin_withdraw_order",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);


    int insert(WithdrawOrder record);

    int insertSelective(WithdrawOrder record);

    int selectCheckStatus(Integer id);

    @Select({
        "select",
        "id, distributor_id, withdraw_id, send_time, check_time, bank_address, bank_card, ",
        "money, remark, status",
        "from brand_admin_withdraw_order",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    WithdrawOrder selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(WithdrawOrder record);

    @Update({
        "update brand_admin_withdraw_order",
        "set distributor_id = #{distributorId,jdbcType=INTEGER},",
          "withdraw_id = #{withdrawId,jdbcType=BIGINT},",
          "send_time = #{sendTime,jdbcType=INTEGER},",
          "check_time = #{checkTime,jdbcType=INTEGER},",
          "bank_address = #{bankAddress,jdbcType=VARCHAR},",
          "bank_card = #{bankCard,jdbcType=VARCHAR},",
          "money = #{money,jdbcType=DECIMAL},",
          "remark = #{remark,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=SMALLINT}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(WithdrawOrder record);
    List<WithdrawOrder> selectWithDrawOrders(@Param("id") Integer id, @Param("timeStart") Long timeStart, @Param("timeEnd") Long timeEnd,
                                             @Param("startPage") Integer startPage, @Param("rowCount") Integer rowCount);

    List<Long> selectCountOrders(@Param("id") Integer id, @Param("timeStart") Long timeStart, @Param("timeEnd") Long timeEnd);
    
    List<WithdrawOrder> selectList(
    		@Param("beginDate") Long beginDate,
    		@Param("endDate") Long endDate,
    		@Param("startIndex") Integer startIndex,
    		@Param("pageSize") Integer pageSize
	);
    
    long findListCount(	@Param("beginDate") Long beginDate,
    		@Param("endDate") Long endDate);
    
    WithdrawOrder selectById(@Param("id") Integer id);
    
    @Update({
        "update brand_admin_withdraw_order",
          "set status = #{status,jdbcType=SMALLINT},check_time=UNIX_TIMESTAMP(NOW()),",
          "remark = #{remark,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
	int updateWithdraw(@Param("id") Integer id,@Param("status") Integer status,@Param("remark") String remark);

}